const db = require('../../../libs/MyDB')
const GetTime = require('../../../libs/GetTime')

module.exports = {

    //获取评论
    comment:  async function(req,res) {
        // return await db.multiSelect('user_comment', ['user_id', 'uimg', 'uname', 'content', 'time'], `course_id = ${req.body.courseid}`)

        return await db.relatedSelect('*', 'study_course_comment', 'study_user', 'user_id', `a.course_id = ${req.body.courseid}`, 'ORDER BY time DESC');
    },


    /**
     * 增加评论
     * @param {*} userid 用户id
     * @param {*} courseid 课程id
     * @param {*} commentContent 课程内容
     * @returns 
     */
    addcomment: async function(userid, courseid, commentContent) {
        // 获取评论时间
        let nowTime = GetTime.getNowFormatDate();
        return await db.add('study_course_comment', {
            user_id: userid,
            course_id: courseid,
            content: commentContent,
            time: nowTime
        })
 
    }

    
}